import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Scanner;

public class NumberEight {
    public static void main(String[] args) {
        ArrayList<Goods> goods=new ArrayList<>();
        goods.add(new Goods("鸭蛋",10));
        goods.add(new Goods("摇头风扇",2));
        goods.add(new Goods("瓢虫项链",5));

        while (true){
            System.out.println("JD秒杀....");
            for (int i = 0; i < goods.size(); i++) {
                System.out.println("商品序号"+(i+1)+":"+goods.get(i));
            }
            System.out.println("选择需要秒杀的商品");
            int a=new Scanner(System.in).nextInt();
            if (LocalTime.now().isBefore(LocalTime.of(14,30,00))){
                switch (a){
                    case 1:
                        if (goods.get(0).getIQuantity()==0){
                            System.out.println("来晚了没了");
                        }else {
                            goods.get(0).setIQuantity(goods.get(0).getIQuantity()-1);
                        }
                        break;
                    case 2:
                        if (goods.get(1).getIQuantity()==0){
                            System.out.println("来晚了没了");
                        }else {
                            goods.get(1).setIQuantity(goods.get(1).getIQuantity()-1);
                        }
                        break;
                    case 3:
                        if (goods.get(2).getIQuantity()==0){
                            System.out.println("来晚了没了");
                        }else {
                            goods.get(2).setIQuantity(goods.get(2).getIQuantity()-1);
                        }
                        break;
                }
            }else {
                System.out.println("活动结束来晚了");

            }


        }




    }

    static class Goods{
        private String name;   //名称
        private int IQuantity;  //库存数量

        public Goods() {
        }

        public Goods(String name, int IQuantity) {
            this.name = name;
            this.IQuantity = IQuantity;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getIQuantity() {
            return IQuantity;
        }

        public void setIQuantity(int IQuantity) {
            this.IQuantity = IQuantity;
        }

        @Override
        public String toString() {
            return "Goods{" +
                    "商品名称='" + name + '\'' +
                    ", 库存数量=" + IQuantity +
                    '}';
        }
    }
}
